#include <mission_list.hpp>

MissionList::MissionList()
	: m_MisId(0)
{
}

MissionList::~MissionList()
{
}

void MissionList::Append(Mission* mission)
{
	if (mission == nullptr)
	{
		return;
	}
	m_MisList.push_back(mission);
}

void MissionList::Clear(bool freeMission)
{
	if (freeMission)
	{
		for (auto it = m_MisList.begin(); it != m_MisList.end();)
		{
			delete *it;				  // 释放当前指针指向的内存
			it = m_MisList.erase(it); // 从列表中删除当前指针，并递增迭代器
		}
	}
	else
	{
		m_MisList.clear();
	}
}

Mission* MissionList::Front()
{
	if (m_MisList.size() <= 0)
	{
		return nullptr;
	}

	return m_MisList.front();
}

void MissionList::Pop()
{
	if (m_MisList.size() <= 0)
	{
		return ;
	}
	m_MisList.pop_front();
}

bool MissionList::IsEmpty(void)
{
	return m_MisList.size() <= 0 ? true : false;
}

void MissionList::SetMisId(int misId)
{
	m_MisId = misId;
}

int MissionList::GetMisId(void)
{
	return m_MisId;
}